<template>
	<view class="page">
		<Header title="车队列表" />
		<view class="" style="height: 160rpx;"></view>
		<!-- 车队列表 -->
		<view class="searchBox">
			<u-search height="80rpx" placeholder="请输入车队名" bgColor="#fff" shape="square" :showAction="false"
				:clearabled="true" v-model="pages.fleetName" @search='search'></u-search>
		</view>
		<view class="fleetList">
			<view class="fleetItem" v-for="(item,index) in fleetData" @click="getDetails(item.fleetId)">
				<image class="fleetIcon" src="@/static/pic/fleetIcon.png" mode="widthFix"></image>
				<view class="infoBox">
					<view class="fleetName">
						{{item.fleetName}}
					</view>
					<view class="address">
						{{item.address}}
					</view>
				</view>
				<image class="rightIcon" src="@/static/pic/right2.png" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>	
import Header from '@/components/header/header.vue'
	export default {
		components: {
			Header
		},
		data() {
			return {

				fleetData: [],
				pages: {
					current: 1,
					size: 10,
					portAddress: 'DRIVER',
					fleetName: '',
				},
				total: 10
			}
		},
		onShow() {
			this.search()
		},
		onReachBottom() {
			this.page.current++
			this.search()
		},
		methods: {
			//搜索车队
			async search() {
				let data = await this.$http.fleet.getFleetList(this.pages)
				if (this.pages.current > 1) {
					if (data.data.data.records.length > 0) {
						this.fleetData = this.fleetData.concat(data.data.data.records)
					} else {
						uni.showToast({
							title: '暂无数据',
							icon: 'none'
						})
						this.page.current = this.page.current - 1; //请求下一页
					}
				} else {
					this.fleetData = data.data.data.records
				}
			},
			// 车队详情
			getDetails(id) {
				// //console.log("id",id);
				uni.navigateTo({
					url: `/pages/my/fleetManage/fleetManage?fleetId=${id}`
				})
			},
		},
		async onLoad(options) {
			//每次进入查询车队信息
			this.search()
		},
	}
</script>

<style lang="scss" scoped>
	.page {
		background: #F3F3F3;
		height: 100vh;
		overflow: scroll;
	}
	
	.searchBox {
		width: 100%;
		box-sizing: border-box;
		padding: 24rpx 30rpx 0;
	
	}
	
	.fleetList {
		padding: 26rpx 30rpx;
		// height:calc(100vh - 300rpx);
		// background-color: red;
		// overflow: scroll;
		.fleetItem {
			margin-bottom: 25rpx;
			box-sizing: border-box;
			padding: 43rpx 46rpx 44rpx 37rpx;
			display: flex;
			align-items: center;
			width: 690rpx;
			background: #FFFFFF;
			border-radius: 10rpx;
			.fleetIcon {
				height: 77.8rpx;
				width: 77.8rpx;
			}
			.infoBox{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				margin-left: 20rpx;
				.fleetName{
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 600;
					color: #202020;
				}
				.address{
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
			.rightIcon{
				width: 35rpx;
				margin-left: auto;
			}
		}
	}
</style>